<template>
	<view class="s-v-box">
		<view class="t-txt" @click="back"><text class="icon-font back-arrow">&#xe604;</text>{{catTitle}}</view>
		<view class="s-c-list-box">
			<view class="scl-tit-box">
				<view class="scl-tit" v-for="(item,index) in gdTabArr" :key="index">
					<view class="txt">{{item}}</view>
				</view>
			</view>
			
			<div class="sc-list-box comm-list-scroll" v-infinite-scroll="getStoreViewListData" v-if="list && list.length>0" >
				<view class="sclb-i" v-for="(item,index) in list" :key="index" @click="onClickGd(item)">
					<view class="i-1">{{item.goods_name}}</view>
					<view class="i-1">{{item.qty_min}}</view>
					<view class="i-1">{{item.amount}}</view>
					<text class="icon-font arrow">&#xe600;</text>
				</view>
			</div>
			<empty v-else/>
		</view>
		
		<popGdStoreWin
		    ref="popGdStoreWin"
		    @editQtyNumUpdate="editQtyNumUpdate"
		></popGdStoreWin>
	</view>
	
</template>

<script>
	import lang from "@/js/conf/Lang.js";
	
	import https from "../../../js/https/Https.js";
	import empty from "../../comm/empty.vue";
	
	import popGdStoreWin from "../../comm/PopGdStoreWin.vue";
	export default{
		components:{empty,popGdStoreWin},
		data()
		{
			return{
				gdTabArr:[
					lang.gdNameLb,
					lang.stockTxt.titleTxt,
					lang.jeTxt,
				],
				catTitle:"",
				list:[],
				pNo:0,
				param:{
					storeid:"",
					catid:"",
					pnum:20,
					pfrom:0,
				}
			}
		},
		methods:
		{
			back()
			{
				this.$emit('backStoreView');
			},
			
			getStoreViewListData(data)
			{
				if(data)
				{
					this.param.storeid = data.storeid;
					this.param.catid = data.catid;
					this.pNo = 0;
					this.list = [];
				}
				this.param.pfrom = this.param.pnum * this.pNo;
				https.getReportStoreViewList(this.param,back);
				let that = this;
				function back(data)
				{
					if(!data)return;
					if(data.status == 1)
					{
						if(!data.data)return;
						data = data.data;
						if(data.info)
						{
							that.catTitle = data.info.cat_name;
						}
						if(data.list)
						{
							that.list = that.list.concat(data.list);
							that.pNo ++;
						}
					}
				}
			},
			
			/****产品库存窗口****/
			onClickGd(item)
			{
				if(!item)return;
				let data = {};
				data.id = item.gdid;
				data.ch = "goods";//"report";
				this.$refs.popGdStoreWin.show("show", data);
			},
			
			/****编辑库存****/
			editQtyNumUpdate(data)
			{
				
			},
			
		}
	}
</script>

<style lang="scss">
	.s-v-box
	{
		width: calc(100% - 344px);
		height: calc(100vh - 53px);
		.t-txt
		{
			padding: 10px;
			font-size: 14px;
			font-weight: bold;
			cursor: pointer;
			.back-arrow
			{
				padding-right: 10px;
			}
		}
		
		.s-c-list-box
		{
			.scl-tit-box
			{
				display: flex;
				justify-content: space-around;
				padding: 3px 0;
				background-color: #EEE;
				border-bottom: 1px solid #EEE;
				font-size: 14px;
				.scl-tit
				{
					display: flex;
					flex: 1;
					padding: 2px 0;
					background-color: #EEE;
					.txt
					{
						width: 100%;
						text-align: center;
					}
				}
			}
		}
		.sc-list-box
		{
			height: calc(100vh - 130px);
			.sclb-i
			{
				border-bottom: 1px solid #EEE;
				padding: 6px 0;
				display: flex;
				
				position: relative;
				cursor: pointer;
				.i-1
				{
					flex: 1;
					text-align: center;
				}
				.arrow
				{
					position: absolute;
					right: 10px;
				}
			}
			.sclb-i:hover
			{
				background-color: #FAFAFA;
			}
		}
	}
</style>